package com.woniuxy01;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;

/**
 * @author 作者
 * @create 2025-09-10 17:26
 */
public class Test05 {
    public static void main(String[] args) {
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime.getYear());
        System.out.println(localDateTime.getMonth());
        System.out.println(localDateTime.get(ChronoField.YEAR));
        System.out.println(localDateTime.get(ChronoField.MONTH_OF_YEAR));
        System.out.println(localDateTime.get(ChronoField.DAY_OF_MONTH));

        //指定日期格式
        DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //日期转字符串
        String str = localDateTime.format(dtf);

        //字符串转日期
        LocalDateTime.parse(null, null);

        //日期运算
        localDateTime.plus(1,null);

//        String gender="男";
//        System.out.println(gender);
//        gender="女";
//        System.out.println(gender);
//        gender="xxxxx";
//        System.out.println(gender);
//
//        Gender gender1=Gender.FEMALE;
//        System.out.println(gender1);


    }

    private static void test01() {
        //获取当前日期时间
        LocalDateTime localDateTime = LocalDateTime.now();
        System.out.println(localDateTime);
        LocalDate localDate = LocalDate.now();
        System.out.println(localDate);
        LocalTime localTime = LocalTime.now();
        System.out.println(localTime);

        //指定时间
        LocalDate localDate1 = LocalDate.of(2000, 1, 1);
        System.out.println(localDate1);
    }
}
